package com.kun.demo01;


import java.util.ArrayList;

//测试Jprofiler的使用
//-Xms1m -Xmx8m -XX:+HeapDumpOnOutOfMemoryError
public class TestJprofiler {

    private Integer[] arr = new Integer[1*1024*1024]; //1M的数组

    public static void main(String[] args) {
        ArrayList<TestJprofiler> list = new ArrayList<>();
        int count =0;
        try {
            while(true){
                list.add(new TestJprofiler());//本行出错，导致内存溢出
                count++;
            }
        }catch (OutOfMemoryError error){
            System.out.println("OutOfMemoryError");
            System.out.println("count="+count);
        }


    }



}
